package leetcode.code0661;

import leetcode.IDebug;

public class Solution implements IDebug {

	public int[][] imageSmoother(int[][] img) {
		int m = img.length, n = img[0].length;
		int[][] ans = new int[m][n];
		int[] direction = new int[] { -1, -1, -1, 0, -1, 1, 0, -1, 0, 0, 0, 1, 1, -1, 1, 0, 1, 1 };
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < n; j++) {
				int sum = 0, num = 0;
				for (int k = 0; k < direction.length; k += 2) {
					int x = i + direction[k], y = j + +direction[k + 1];
					if (x >= 0 && x < m && y >= 0 && y < n) {
						sum += img[x][y];
						num += 1;
					}
				}
				ans[i][j] = sum / num;
			}
		}
		return ans;
	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
